/* eslint-disable class-methods-use-this */
import {
  get,
  put,
  _delete,
} from '@/lin/plugins/axios'

// 我们通过 class 这样的语法糖使模型这个概念更加具象化，其优点：耦合性低、可维护性。
class Order {
  async getGoodsList(page, limit, info) {
    const res = await get(`v1/order/goods?page=${page}&limit=${limit}`, info)
    return res
  }

  async getGoodsExcelList(info) {
    const res = await get('v1/order/excel/goods', info)
    return res
  }

  async updateGoodsOrder(info) {
    const res = await put('v1/order/goods', info)
    return res
  }

  async updateGoodsOrderOne(info) {
    const res = await put('v1/order/goods_one', info)
    return res
  }

  async getStoreList(page, limit, info) {
    const res = await get(`v1/order/store?page=${page}&limit=${limit}`, info)
    return res
  }

  async getStoreExcelList(info) {
    const res = await get('v1/order/excel/store', info)
    return res
  }

  async updateStoreOrder(info) {
    const res = await put('v1/order/store', info)
    return res
  }

  async deleteStoreOrder(id) {
    const res = await _delete(`v1/order/store/${id}`)
    return res
  }

  async updateGoodsOneOrder(id) {
    const res = await put(`v1/order_goods/${id}`)
    return res
  }

  async refundGoodsOrder(id) {
    const res = await _delete(`v1/order/goods/${id}`)
    return res
  }
}

export default new Order()
